//
//  ZLViewController.m
//  ZLAlert-OC
//
//  Created by 赵振磊 on 01/02/2024.
//  Copyright (c) 2024 赵振磊. All rights reserved.
//

#import "ZLViewController.h"
#import <ZLAlert_OC/ZLAlert-OC.h>

@interface ZLViewController ()

@end

@implementation ZLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewDidAppear:(BOOL)animated  {
    [super viewDidAppear:animated];
    [self showMenu];
}

- (void)showMenu {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"演示示例"];
    [alert addLine];
    [alert addButton:@"一个标题" action:^{
        [self showTitle];
    }];
    [alert addLine];
    [alert addButton:@"标题+内容" action:^{
        [self showContent];
    }];
    [alert addLine];
    [alert addButton:@"标题+内容+1个按钮" action:^{
        [self showContentButton];
    }];
    [alert addLine];
    [alert addButton:@"标题+内容+2个按钮" action:^{
        [self showContentButton2];
    }];
    [alert addLine];
    [alert addButton:@"标题+输入框+2个按钮" action:^{
        [self showTextfieldButton2];
    }];
    [alert addLine];
    [alert addButton:@"随意" action:^{
        [self showfree];
    }];
    [alert show];
}

- (void)showTitle {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"标题"];
    [alert showWithTapBackgroundClose:^{
        NSLog(@"点击背景关闭");
        [self showMenu];
    }];
}

- (void)showContent {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"标题"];
    [alert addSpace:5];
    [alert addContent:@"内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"];
    [alert showWithTapBackgroundClose:^{
        NSLog(@"点击背景关闭");
        [self showMenu];
    }];
}

- (void)showContentButton {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"标题"];
    [alert addSpace:5];
    [alert addContent:@"内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"];
    [alert addButton:@"按钮" action:^{
        [self showMenu];
    }];
    [alert show];
}

- (void)showContentButton2 {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"标题"];
    [alert addSpace:5];
    [alert addContent:@"内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"];
    [alert addDoubleAction:@"左侧" leftAction:^{
        [self showMenu];
    } showCenterLine:YES rightTitle:@"右侧" rightAction:^{
        [self showMenu];
    }];
    [alert show];
}

- (void)showTextfieldButton2 {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"标题"];
    [alert addSpace:5];
    [alert addTextField:@"输入提示" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"编辑完成：%@", text);
    }];
    [alert addDoubleAction:@"左侧" leftAction:^{
        [self showMenu];
    } showCenterLine:YES rightTitle:@"右侧" rightAction:^{
        [self showMenu];
    }];
    [alert show];
}

- (void)showfree {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"标题"];
    [alert addSpace:5];
    [alert addImage:[UIImage imageNamed:@"xx"]];
    [alert addSpace:5];
    [alert addContent:@"内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容"];
    [alert addSpace:5];
    [alert addLine];
    [alert addSpace:5];
    [alert addTextField:@"输入提示" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"编辑完成：%@", text);
    }];
    [alert addSpace:5];
    [alert addLine];
    [alert addDoubleAction:@"左侧" leftAction:^{
        [self showMenu];
    } showCenterLine:YES rightTitle:@"右侧" rightAction:^{
        [self showMenu];
    }];
    [alert addLine];
    [alert addSpace:5];
    [alert addTextField:@"输入提示2" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"编辑完成：%@", text);
    }];
    [alert addSpace:5];
    [alert addLine];
    [alert addDoubleAction:@"左侧2" leftAction:^{
        [self showMenu];
    } showCenterLine:YES rightTitle:@"右侧2" rightAction:^{
        [self showMenu];
    }];
    [alert addLine];
    [alert addSpace:5];
    UIView *customView = [[UIView alloc] initWithFrame:CGRectZero];
    customView.backgroundColor = [UIColor orangeColor];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.backgroundColor = [UIColor yellowColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = @"自定义view";
    [customView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.height.equalTo(@50);
        make.bottom.equalTo(customView).offset(-10);
    }];
    [alert addCustomView:customView];
    [alert addSpace:5];
    [alert addTextField:@"输入提示3" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"编辑完成：%@", text);
    }];
    [alert addSpace:5];
    [alert addButton:@"关闭" action:^{
        [self showMenu];
    }];
    [alert addSpace:5];
    [alert show];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    ZLAlert *alert = [[ZLAlert alloc] init];
    [alert addTitle:@"提示"];
    [alert addTitle:@"提示"];
    [alert addSpace:5];
    [alert addContent:@"666666666sdfsdfsf撒打发斯蒂芬收到防守打法四大发撒"];
    [alert addTextField:@"np" editEnd:^(NSString * _Nonnull text) {
        
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString * _Nonnull text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString *text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addTextField:@"说牛批" editEnd:^(NSString *text) {
        NSLog(@"你输入了: %@", text);
    }];
    [alert addSpace:5];
    [alert addButton:@"确定" action:^{
        NSLog(@"点击确定");
    }];
    [alert addLine];
    [alert addDoubleAction:@"确定" leftAction:^{
        
    } showCenterLine:YES rightTitle:@"取消" rightAction:^{
        
    }];
    [alert show];
}

@end
